/**   
 * @Title: BeidanChooseList.java 
 * @Package com.esun.rabbit2.viewer.mainact.lotteryhallact.beidanapg 
 * @Description: 北单选择页面
 * @author:Kael gaojian@500wan.com   
 * @date: 2012-4-6 上午9:40:57
 * Copyright: (C) 2011 Shenzhen E-sun Sky Net Technology Co.,ltd.
 */
package com.esun.rabbit2.viewer.mainact.lotteryhallact.beidanagp;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Hashtable;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Handler;
import android.os.Message;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.view.animation.AnimationUtils;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.BaseExpandableListAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ExpandableListView;
import android.widget.GridView;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AbsListView.OnScrollListener;
import android.widget.CompoundButton.OnCheckedChangeListener;
import com.esun.config.Config;
import com.esun.config.Key;
import com.esun.config.Language;
import com.esun.model.UserInfo;
import com.esun.model.beijingdanchang.BeidanAgainstInfo;
import com.esun.model.beijingdanchang.BeidanLotteryInfo;
import com.esun.rabbit2.communicaters.beijingdanchang.BeiDanGetTeamListCommunicater;
import com.esun.rabbit2.communicaters.beijingdanchang.BeidanHotAgainstInfoCommunicater;
import com.esun.rabbit2.communicaters.beijingdanchang.BeidanNoFilterAgainstInfoCommunicater;
import com.esun.rabbit2.viewer.LoginAct;
import com.esun.rabbit2.viewer.mainact.lotteryhallact.BeidanAgp;
import com.esun.rabbit2.viewer.mainact.lotteryhallact.SportteryBuyLottery;
import com.esun.rabbit2.viewer.mainact.lotteryhallact.SportteryChooseActivity;
import com.esun.rabbit2.viewer.mainact.lotteryhallact.SportteryChooseList;
import com.esun.ui.R;
import com.esun.util.ViewerUtil;
import com.esun.util.img.ImageListCache;
import com.esun.util.log.EDebug;

/**
 * @ClassName: BeidanChooseList
 * @Description: 北单选择页面
 * @author: kael gaojian@500wan.com
 * @date: 2012-4-6 上午9:40:57
 * 
 */
public class BeidanChooseList extends SportteryChooseList implements OnClickListener, OnScrollListener {
	private Context context;
	private View view;
	private SportteryBuyLottery buyLotteryPage;
	private Button btnClaen;// 清除
	private Button btnSubmit;// 提交
	private Button btnRefresh;// 刷新
	private ArrayList<Hashtable<String, Object>> listContent;
	private ArrayList<BeidanAgainstInfo> listInfo;
	private TeamListAdapter teamListAdapter;// 队伍列表适配器
	private GridView gridSaishiList;// 赛事列表GridView
	private RadioGroup rgTop;

	private ExpandableListView expandableListViewContent;
	private BeidanExpandableListAdapter beiDanExpandableListAdapter;
	private int type;// 玩法类型

	private LinearLayout linearTitle;
	private TextView tvDate;
	private TextView tvSaishiCount;
	private ImageView imgExpand;

	private ArrayList<Boolean> saishiItemCheckedList;// 保存赛事是否选择的List
	private BeiDanGetTeamListCommunicater beiDanGetTeamListCommunicater = new BeiDanGetTeamListCommunicater();// 获取北单联赛列表通信接口
	private BeidanNoFilterAgainstInfoCommunicater beiDanNoFilterAgainstInfoCommunicater;// 获取全部北单比赛信息通信接口
	private BeidanHotAgainstInfoCommunicater beiDanHotAgainstInfoCommunicater;// 获取北单热门赛事通信接口
	public static Handler handlerChoosePage;

	// 当前的通信状态
	private boolean isGettingTeamList = false;
	private boolean isUpdateAgainstList = false;
	private boolean isHot = false;
	private ArrayList<Object[]> listImageCache = new ArrayList<Object[]>();// 图片缓存

	private RelativeLayout progressdialogRefresh;

	private ImageListCache imageListCache = null;

	private ArrayList<View> alViewsList = new ArrayList<View>();

	// private int indicatorGroupId = -1;

	/** 本地筛选工具 */
	AgainstTeamListLocalFilter againstTeamListLocalFilter;

	public BeidanChooseList(Context context, View view) {
		this.view = view;
		this.context = context;
		handlerInit();
		init();
		refresh();
	}

	/**
	 * @Title: handlerInit
	 * @Description: 初始化Handler
	 * @param: 设定文件
	 * @return: void 返回类型
	 * @throws
	 */
	private void handlerInit() {
		handlerChoosePage = new Handler() {
			public void handleMessage(Message msg) {
				switch (msg.what) {
				// 获取联赛列表成功
				case GETTEAMLIST_SUCCEED:
					isGettingTeamList = false;
					beiDanGetTeamListCommunicater.updateTeamInfo();
					EDebug.o(BeidanChooseList.this, "获取联赛列表成功");
					Message msgToGroup = BeidanAgp.handlerBeidanAgp.obtainMessage(BeidanAgp.NO_FILTER, null);
					BeidanAgp.handlerBeidanAgp.sendMessage(msgToGroup);
					updateDialogFilter();
					break;
				// 获取对阵列表成功
				case GETAGAINSTLIST_SUCCEED:
					isUpdateAgainstList = false;
					getAgainstSucceed();
					break;
				// 获取热门赛事成功
				case GETRECOMMENDAGAINSTLIST_SUCCEED:
					isUpdateAgainstList = false;
					getHotAgainstSucceed();
					break;
				// 执行刷新
				case DO_REFRESH:
					refresh();
					break;
				case DO_FINISH:
					((Activity) context).getParent().finish();
					break;
				// 执行清除
				case DO_CLEAR:
					cleanListView();
					break;
				// 页面切换时list的修改
				case DO_BACK_UPDATE:

					listContent.clear();
					listContent.addAll(BeidanLotteryInfo.getBeiDanLotteryInfo().getLotterList());
					expandableListProcesForPageSwich();

					break;
				// 获取对阵列表失败
				case GETAGAINSTLIST_FAIL:

					isUpdateAgainstList = false;
					beiDanExpandableListAdapter.notifyDataSetChanged();
					linearTitle.setVisibility(View.INVISIBLE);
					progressdialogRefresh.setVisibility(View.INVISIBLE);
					Toast.makeText(context, beiDanNoFilterAgainstInfoCommunicater.getServerMsg(), Toast.LENGTH_SHORT).show();

					break;
				// 获取热门赛事失败
				case GETRECOMMENDAGAINSTLIST_FAIL:

					isUpdateAgainstList = false;
					listGroup.clear();
					listChild.clear();
					beiDanExpandableListAdapter.notifyDataSetChanged();
					linearTitle.setVisibility(View.INVISIBLE);
					progressdialogRefresh.setVisibility(View.INVISIBLE);
					Toast.makeText(context, beiDanHotAgainstInfoCommunicater.getServerMsg(), Toast.LENGTH_SHORT).show();

					break;
				// 获取联赛列表失败
				case GETTEAMLIST_FAIL:

					isGettingTeamList = false;
					progressdialogRefresh.setVisibility(View.INVISIBLE);
					Toast.makeText(context, beiDanGetTeamListCommunicater.getServerMsg(), Toast.LENGTH_SHORT).show();

					break;
				// 连接失败
				case Config.CONNECTION_FAIL:

					beiDanExpandableListAdapter.notifyDataSetChanged();
					linearTitle.setVisibility(View.INVISIBLE);
					isUpdateAgainstList = false;
					progressdialogRefresh.setVisibility(View.INVISIBLE);
					Toast.makeText(context, Language.STR_CONNECTIONFAIL, Toast.LENGTH_SHORT).show();

					break;
				// 获取联赛列表通信连接失败
				case GETTEAMLIST_CONNECTION_FAIL:

					isGettingTeamList = false;
					progressdialogRefresh.setVisibility(View.INVISIBLE);
					Toast.makeText(context, Language.STR_CONNECTIONFAIL, Toast.LENGTH_SHORT).show();

					break;
				// 筛选
				case DO_FILTER:

					showDialogFilter();

					break;
				// 获取图片成功
				case GET_IMAGECACHE_SUCCEED:

					if (imageListCache == null) {
						EDebug.o(BeidanChooseList.this, "加载触发,走你");
						EDebug.o(BeidanChooseList.class, " creat object !!" + listImageCache.size());
						imageListCache = new ImageListCache(context, listImageCache);
					} else {
						EDebug.o(BeidanChooseList.this, "重加载触发,走你");
						imageListCache.addToLine(listImageCache);
					}
					if (scrollViewFilter != null) {
						EDebug.o(BeidanChooseList.this, "线程触发,scrollto 0");
						scrollViewFilter.scrollTo(0, 0);
					}

					break;
				default:
					break;
				}
			}

		};
	}

	/**
	 * @Title: updateDialogFilter
	 * @Description: 修改筛选状态
	 * @param: 设定文件
	 * @return: void 返回类型
	 * @throws
	 */
	private void updateDialogFilter() {
		// boolean 列表,存放checkbox状态
		saishiItemCheckedList.clear();
		// String 选中的联赛名称
		listSelectedLeagueNmae.clear();
		// View 缓存adapter中的view
		alViewsList.clear();
		// object[] 调用图片加载
		listImageCache.clear();
		if (imageListCache != null) {
			imageListCache = null;
		}
		ArrayList<Hashtable<String, Object>> simpleLeagueList = new ArrayList<Hashtable<String, Object>>();
		simpleLeagueList = BeidanLotteryInfo.getBeiDanLotteryInfo().getSimpleLeagueList();
		for (int i = 0; i < simpleLeagueList.size(); i++) {
			saishiItemCheckedList.add((Boolean) simpleLeagueList.get(i).get(IS_CHECKED));
			listSelectedLeagueNmae.add((String) simpleLeagueList.get(i).get(SAISHI_NAME));
		}
	}

	/**
	 * @Title: getAgainstSucceed
	 * @Description: 获取对阵列表成功
	 * @param: 设定文件
	 * @return: void 返回类型
	 * @throws
	 */
	private void getAgainstSucceed() {
		try {
			progressdialogRefresh.setVisibility(View.INVISIBLE);
		} catch (Exception e) {
			EDebug.o(BeidanChooseList.this, e.toString());
		}
		listInfo.clear();
		listInfo.addAll(beiDanNoFilterAgainstInfoCommunicater.getAgainstInfoList());
		sortListInfo();
		updateListContent();
		updateListExpandadble(listContent, true, true);
		beiDanExpandableListAdapter.notifyDataSetChanged();
		updateTitleView(0);
		for (int i = 0; i < listGroup.size(); i++)
			expandableListViewContent.expandGroup(i);
		EDebug.o("expandableListViewContent.expandGroup(i)");
	}

	/**
	 * @Title: getRecommendAgainstSucceed
	 * @Description: 获取热门赛事成功
	 * @param: 设定文件
	 * @return: void 返回类型
	 * @throws
	 */
	private void getHotAgainstSucceed() {
		try {
			progressdialogRefresh.setVisibility(View.INVISIBLE);
		} catch (Exception e) {
			EDebug.o(BeidanChooseList.this, e.toString());
		}

		listInfo.clear();
		listInfo.addAll(beiDanHotAgainstInfoCommunicater.getAgainstInfoList());
		sortListInfo();
		updateListContent();
		updateListExpandadble(listContent, true, true);
		beiDanExpandableListAdapter.notifyDataSetChanged();

		updateTitleView(0);
		for (int i = 0; i < listGroup.size(); i++)
			expandableListViewContent.expandGroup(i);
	}

	public View getView() {
		((SportteryChooseActivity) context).setCurrentPageFlag(0);
		Message msg = BeidanAgp.handlerBeidanAgp.obtainMessage(BeidanAgp.IN_CHOOSE_VIEW, null);
		BeidanAgp.handlerBeidanAgp.sendMessage(msg);
		return view;
	}

	/**
	 * @Title: refresh
	 * @Description: 刷新
	 * @param: 设定文件
	 * @return: void 返回类型
	 * @throws
	 */
	private void refresh() {
		if (canCommunicate()) {
			progressdialogRefresh.setVisibility(View.VISIBLE);
			type = 2;
			rangqiuType = 0;
			peilvType = 0;
			if (isHot) {
				threadHotAgainst();
			} else {
				threadAgainst();
			}
			threadGetTeamList();
		} else {
			EDebug.o(BeidanChooseList.this, " 通信中..");
		}
	}

	/**
	 * @Title: init
	 * @Description: 初始化
	 * @param: 设定文件
	 * @return: void 返回类型
	 * @throws
	 */
	private void init() {

		btnClaen = (Button) view.findViewById(R.id.beidanchooseact_btn_clean);
		btnSubmit = (Button) view.findViewById(R.id.beidanchooseact_btn_submit);
		btnRefresh = (Button) view.findViewById(R.id.beidanchooseact_btn_refresh);

		btnClaen.setOnClickListener(this);
		btnSubmit.setOnClickListener(this);
		btnRefresh.setOnClickListener(this);

		listContent = new ArrayList<Hashtable<String, Object>>();
		listInfo = new ArrayList<BeidanAgainstInfo>();

		beiDanNoFilterAgainstInfoCommunicater = new BeidanNoFilterAgainstInfoCommunicater();
		beiDanHotAgainstInfoCommunicater = new BeidanHotAgainstInfoCommunicater();

		expandableListViewContent = (ExpandableListView) view.findViewById(R.id.beidanchooseact_expandalblelistview_content);
		beiDanExpandableListAdapter = new BeidanExpandableListAdapter(context);
		expandableListViewContent.setAdapter(beiDanExpandableListAdapter);
		expandableListViewContent.setOnScrollListener(this);

		for (int i = 0; i < listInfo.size(); i++) {
			EDebug.o(BeidanChooseList.this, listInfo.get(i).getSchedulesDate());
		}
		for (int i = 0; i < listContent.size(); i++) {
			EDebug.o(BeidanChooseList.this, "is title = " + listContent.get(i).get(IS_TITLE));
		}
		// 赛事选择列表初始化
		saishiItemCheckedList = new ArrayList<Boolean>();

		linearTitle = (LinearLayout) view.findViewById(R.id.beidanchooseact_linear_title);
		tvDate = (TextView) view.findViewById(R.id.beidanchooseact_tv_date);
		tvSaishiCount = (TextView) view.findViewById(R.id.beidanchooseact_tv_mtachCount);
		imgExpand = (ImageView) view.findViewById(R.id.beidanchooseact_img_expand);
		linearTitle.setVisibility(View.GONE);

		progressdialogRefresh = (RelativeLayout) view.findViewById(R.id.beidan_relative_progress);
		progressdialogRefresh.setOnClickListener(this);
		BeidanLotteryInfo.getBeiDanLotteryInfo().getAllLeagueList().clear();
		BeidanLotteryInfo.getBeiDanLotteryInfo().getBeiDanHotLeagueList().clear();
		initRadioGroupTop();
	}

	/**
	 * @Title: initRadioGroupTop
	 * @Description: 初始化列表头部：全部联赛、热门投注
	 * @param: 设定文件
	 * @return: void 返回类型
	 * @throws
	 */
	private void initRadioGroupTop() {
		rgTop = (RadioGroup) view.findViewById(R.id.beidanchooseact_rg_top);
		rgTop.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
			@Override
			public void onCheckedChanged(RadioGroup group, int checkedId) {
				ArrayList<Hashtable<String, Object>> hotLeagueList = new ArrayList<Hashtable<String, Object>>();
				ArrayList<Hashtable<String, Object>> allLeagueList = new ArrayList<Hashtable<String, Object>>();
				hotLeagueList = BeidanLotteryInfo.getBeiDanLotteryInfo().getBeiDanHotLeagueList();
				allLeagueList = BeidanLotteryInfo.getBeiDanLotteryInfo().getAllLeagueList();
				switch (checkedId) {

				// 全部赛事
				case R.id.beidanchooseact_rb_all:
					isHot = false;
					hotLeagueList.clear();
					hotLeagueList.addAll(listContent);
					listContent.clear();
					if (allLeagueList.isEmpty()) {
						listGroup.clear();
						listChild.clear();
						refresh();
					} else {
						listContent.addAll(allLeagueList);
						expandableListProcesForPageSwich();
					}
					break;
				// 热门赛事
				case R.id.beidanchooseact_rb_recommend:
					isHot = true;
					allLeagueList.clear();
					allLeagueList.addAll(listContent);
					listContent.clear();
					if (hotLeagueList.isEmpty()) {
						listGroup.clear();
						listChild.clear();
						refresh();
					} else {
						listContent.addAll(hotLeagueList);
						expandableListProcesForPageSwich();
					}
					break;

				default:
					break;
				}
			}
		});
	}

	/**
	 * @Title: expandableListProcesForPageSwich
	 * @Description: 页面切换时ExpandableListView的处理, 筛选显示, adapter加载, ScrollView滚至最上,更新TitleBar显示, 展开每一条group
	 * @param: 设定文件
	 * @return: void 返回类型
	 * @throws
	 */
	private void expandableListProcesForPageSwich() {
		if (listSelectedLeagueNmae.isEmpty()) {
			updateListExpandadble(listContent, true, true);
		} else {
			updateListExpandadble(listContent, false, false);
		}
		beiDanExpandableListAdapter.notifyDataSetChanged();
		expandableListViewContent.setSelectedGroup(0);
		updateTitleView(0);
		for (int i = 0; i < listGroup.size(); i++)
			expandableListViewContent.expandGroup(i);
	}

	/**
	 * @Title: threadAgainst
	 * @Description: 获取对阵信息线程
	 * @param: 设定文件
	 * @return: void 返回类型
	 * @throws
	 */
	private void threadAgainst() {
		/** 推荐赛事加入 */
		isUpdateAgainstList = true;
		new Thread() {
			@Override
			public void run() {
				super.run();
				try {
					/** 获取全部对阵信息接口 */
					boolean b = beiDanNoFilterAgainstInfoCommunicater.isGetInfoSucceed();
					if (b) {
						Message msg = handlerChoosePage.obtainMessage(GETAGAINSTLIST_SUCCEED, null);
						handlerChoosePage.sendMessage(msg);
					} else {
						Message msg = handlerChoosePage.obtainMessage(GETAGAINSTLIST_FAIL, null);
						handlerChoosePage.sendMessage(msg);
					}
				} catch (Exception e) {
					Message msg = handlerChoosePage.obtainMessage(Config.CONNECTION_FAIL, null);
					handlerChoosePage.sendMessage(msg);
				}
			}
		}.start();
	}

	/**
	 * @Title: threadHotAgainst
	 * @Description: 获取热门投注信息线程
	 * @param: 设定文件
	 * @return: void 返回类型
	 * @throws
	 */
	private void threadHotAgainst() {
		/** 推荐赛事加入 */
		isUpdateAgainstList = true;
		new Thread() {
			@Override
			public void run() {
				super.run();
				try {
					/** 获取全部对阵信息接口 */
					boolean b = beiDanHotAgainstInfoCommunicater.isGetInfoSucceed();
					if (b) {
						Message msg = handlerChoosePage.obtainMessage(GETRECOMMENDAGAINSTLIST_SUCCEED, null);
						handlerChoosePage.sendMessage(msg);
					} else {
						Message msg = handlerChoosePage.obtainMessage(GETRECOMMENDAGAINSTLIST_FAIL, null);
						handlerChoosePage.sendMessage(msg);
					}
				} catch (Exception e) {
					Message msg = handlerChoosePage.obtainMessage(Config.CONNECTION_FAIL, null);
					handlerChoosePage.sendMessage(msg);
				}
			}
		}.start();
	}

	/**
	 * @Title: canCommunicate
	 * @Description: 验证是否可以通信
	 * @param: @return 设定文件
	 * @return: boolean 返回类型
	 * @throws
	 */
	private boolean canCommunicate() {
		boolean b;
		if (!isGettingTeamList && !isUpdateAgainstList) {
			b = true;
		} else {
			b = false;
		}
		return b;
	}

	/**
	 * @Title: threadGetTeamList
	 * @Description: 获取联赛列表通信线程
	 * @param: 设定文件
	 * @return: void 返回类型
	 * @throws
	 */
	private void threadGetTeamList() {
		isGettingTeamList = true;
		new Thread() {
			@Override
			public void run() {
				super.run();
				try {
					boolean b = beiDanGetTeamListCommunicater.isGetTeamListSucceed();
					if (b) {
						Message msg = handlerChoosePage.obtainMessage(GETTEAMLIST_SUCCEED, null);
						handlerChoosePage.sendMessage(msg);
					} else {
						Message msg = handlerChoosePage.obtainMessage(GETTEAMLIST_FAIL, null);
						handlerChoosePage.sendMessage(msg);
					}
				} catch (Exception e) {

					Message msg = handlerChoosePage.obtainMessage(GETTEAMLIST_CONNECTION_FAIL, null);
					handlerChoosePage.sendMessage(msg);
				}
			}
		}.start();
	}

	/**
	 * @Title: updateListContent
	 * @Description: 修改ListView内容
	 * @param: 设定文件
	 * @return: void 返回类型
	 * @throws
	 */
	private void updateListContent() {
		int titleTaget = 0; // title在列表中的位置
		int itemCount = 1; // 相同title下元素个数
		if (listInfo.size() > 0) {
			listContent.clear();
			listContent.add(tableInListContentIsTitle(0, itemCount));
			listContent.add(tableInListContentNotTitle(0));
			for (int i = 1; i < listInfo.size(); i++) {

				if (listInfo.get(i).getSchedulesDate().equals(listInfo.get(i - 1).getSchedulesDate())) {
					listContent.add(tableInListContentNotTitle(i));
					itemCount++;
					listContent.get(titleTaget).put(ITEM_COUNT, itemCount);

				} else {
					EDebug.o(BeidanChooseList.this, "date is " + listInfo.get(i).getSchedulesDate());
					EDebug.o(BeidanChooseList.this, "date before is " + listInfo.get(i - 1).getSchedulesDate());
					itemCount = 1;
					titleTaget = listContent.size();
					EDebug.o(BeidanChooseList.this, "title taget is " + titleTaget);
					listContent.add(tableInListContentIsTitle(i, itemCount));
					listContent.add(tableInListContentNotTitle(i));
				}
			}
		} else {
			listContent.clear();
		}
	}

	/**
	 * @Title: updateListExpandadble
	 * @Description: 加载列表
	 * @param: @param list
	 * @param: @param isAll 设定文件
	 * @return: void 返回类型
	 * @throws
	 */
	private void updateListExpandadble(ArrayList<Hashtable<String, Object>> list, boolean isAll, boolean isPvAll) {

		againstTeamListLocalFilter = new AgainstTeamListLocalFilter(list);
		againstTeamListLocalFilter.getResult(rangqiuType, peilvType, listSelectedLeagueNmae, isAll, isPvAll);

		listChild.clear();
		listGroup.clear();
		listChildView.clear();
		for (int i = 0; i < list.size(); i++) {
			if ((Boolean) list.get(i).get(IS_TITLE)) {
				listGroup.add(list.get(i));
				ArrayList<Hashtable<String, Object>> listChild_ = new ArrayList<Hashtable<String, Object>>();
				listChild.add(listChild_);
				ArrayList<View> listChildView_ = new ArrayList<View>();
				listChildView.add(listChildView_);
			} else if ((Boolean) list.get(i).get(IS_SHOW)) {
				list.get(i).put(Key.KEY_POSITION, i);
				listChild.get(listChild.size() - 1).add(list.get(i));
			} else {
				list.get(i).put(Key.KEY_POSITION, i);
			}
		}
		for (int i = 0; i < listGroup.size(); i++) {
			listGroup.get(i).put(ITEM_COUNT, listChild.get(i).size());
		}
	}

	/**
	 * @Title: tableInListContentNotTitle
	 * @Description: 设置一场比赛的内容
	 * @param: @param position
	 * @param: @return 设定文件
	 * @return: Hashtable<String,Object> 返回类型
	 * @throws
	 */
	private Hashtable<String, Object> tableInListContentNotTitle(int position) {
		Hashtable<String, Object> hashtable = new Hashtable<String, Object>();
		hashtable.put(INFO, listInfo.get(position));
		hashtable.put(IS_TITLE, false);
		hashtable.put(W, false);
		hashtable.put(D, false);
		hashtable.put(L, false);
		hashtable.put(IS_ACTIVE, false);
		hashtable.put(Key.KEY_IS_DAN, false);
		hashtable.put(Key.KEY_IS_SHOW, true);
		return hashtable;
	}

	/**
	 * @Title: tableInListContentIsTitle
	 * @Description: 设置一项二级列表标题的内容
	 * @param: @param position
	 * @param: @param itemCount
	 * @param: @return 设定文件
	 * @return: Hashtable<String,Object> 返回类型
	 * @throws
	 */
	private Hashtable<String, Object> tableInListContentIsTitle(int position, int itemCount) {
		Hashtable<String, Object> hashtable = new Hashtable<String, Object>();
		hashtable.put(ITEM_COUNT, itemCount);
		hashtable.put(IS_TITLE, true);
		hashtable.put(DATE, listInfo.get(position).getSchedulesDate());
		hashtable.put(Key.KEY_EXPECT, listInfo.get(position).getExpect());
		hashtable.put(DAY_OF_WEEK, listInfo.get(position).getMatchWeek());
		hashtable.put(IS_ACTIVE, false);
		hashtable.put(IS_DAN, false);
		hashtable.put(IS_SHOW, true);
		return hashtable;
	}

	@Override
	public void onClick(View v) {

		if (isGettingTeamList) {
			Toast.makeText(context, "信息加载中...", 500).show();
		} else {
			switch (v.getId()) {

			case R.id.beidanchooseact_btn_refresh:// 刷新
				Message msg = handlerChoosePage.obtainMessage(DO_REFRESH, null);
				handlerChoosePage.sendMessage(msg);
				break;

			case R.id.beidanchooseact_btn_clean:// 清理
				cleanListView();
				break;

			case R.id.beidanchooseact_btn_submit:// 提交
				if (getActiveTeamCount() < getLimitEventCount()) {
					ViewerUtil.showTipDialog(context, "最少选择" + getLimitEventCount() + "场比赛", false);
				} else if (UserInfo.getUserInfo().getUserSession().length() < 3) {
					Intent intent = new Intent();
					intent.setClass(context, LoginAct.class);
					((Activity) context).startActivity(intent);
				} else {
					BeidanLotteryInfo.getBeiDanLotteryInfo().getLotterList().clear();
					BeidanLotteryInfo.getBeiDanLotteryInfo().getLotterList().addAll(listContent);
					((Activity) context).setContentView(buyLotteryPage.getView());
				}
				break;

			default:
				break;
			}
		}
	}

	/**
	 * @Title: getLimitEventCount
	 * @Description: 已选中比赛场数
	 * @param: @return 设定文件
	 * @return: int 返回类型
	 * @throws
	 */
	private int getLimitEventCount() {
		int i = 0;
		if (type == 1) {
			i = 1;
		} else if (type == 2) {
			// 北单有单关玩法，可以之选一场
			// i = 2;
			i = 1;
		}
		return i;
	}

	/**
	 * @Title: cleanListView
	 * @Description: 清除列表
	 * @param: 设定文件
	 * @return: void 返回类型
	 * @throws
	 */
	private void cleanListView() {

		for (int i = 0; i < listContent.size(); i++) {
			Hashtable<String, Object> listContentPer = new Hashtable<String, Object>();
			listContentPer = listContent.get(i);
			if (!(Boolean) listContentPer.get(IS_TITLE)) {
				listContentPer.put(W, false);
				listContentPer.put(D, false);
				listContentPer.put(L, false);
				listContentPer.put(IS_ACTIVE, false);
				listContentPer.put(IS_DAN, false);
			}
		}
		updateListExpandadble(listContent, false, false);
		beiDanExpandableListAdapter.notifyDataSetChanged();
	}

	/**
	 * @Title: sortListInfo
	 * @Description: 对返回列表进行日期排序
	 * @param: 设定文件
	 * @return: void 返回类型
	 * @throws
	 */
	@SuppressWarnings({ "rawtypes", "unchecked" })
	private void sortListInfo() {
		Collections.sort(listInfo, new Comparator() {
			@Override
			public int compare(Object object1, Object object2) {
				BeidanAgainstInfo sa1 = (BeidanAgainstInfo) object1;
				BeidanAgainstInfo sa2 = (BeidanAgainstInfo) object2;
				int i = (sa1.getSchedulesDate()).compareTo(sa2.getSchedulesDate());
				return i;
			}
		});

	}

	/**
	 * @Title: updateTableLottery
	 * @Description: 修改列表中的选中状态
	 * @param: @param position
	 * @param: @param w
	 * @param: @param d
	 * @param: @param l
	 * @param: @param cbx
	 * @param: @param key
	 * @param: @param beiDanballAgainstInfo 设定文件
	 * @return: void 返回类型
	 * @throws
	 */
	private void updateTableLottery(int position, boolean w, boolean d, boolean l, CheckBox cbx, String key, BeidanAgainstInfo beiDanAgainstInfo) {
		boolean isChecked = false;
		if (key.equals(W)) {
			isChecked = w;
		} else if (key.equals(D)) {
			isChecked = d;
		} else if (key.equals(L)) {
			isChecked = l;
		} else {
			EDebug.o(BeidanChooseList.this, "sun your sister ...");
		}
		if (getActiveTeamCount() > getMaxTeamNum() - 1 && !(Boolean) listContent.get(position).get(IS_ACTIVE)) {
			cbx.setChecked(false);
			Toast.makeText(context, "最多选择" + getMaxTeamNum() + "场比赛", Toast.LENGTH_SHORT).show();
		} else {
			listContent.get(position).put(key, isChecked);
			listContent.get(position).put(IS_ACTIVE, true);

			if (!w && !d && !l) {
				listContent.get(position).put(IS_ACTIVE, false);
			}
		}
	}

	/**
	 * @Title: getActiveTeamCount
	 * @Description: 正在比赛的队伍数量
	 * @param: @return 设定文件
	 * @return: int 返回类型
	 * @throws
	 */
	private int getActiveTeamCount() {
		int activeTeamCount = 0;
		for (int i = 0; i < listContent.size(); i++) {
			if ((Boolean) listContent.get(i).get(IS_ACTIVE)) {
				activeTeamCount++;
			}
		}
		return activeTeamCount;
	}

	/**
	 * @ClassName: TeamListAdapter
	 * @Description: 联赛列表适配器
	 * @author: Kael gaojian@500wan.com
	 * @date: 2012-4-12 上午10:59:07
	 * 
	 */
	class TeamListAdapter extends BaseAdapter {
		private LayoutInflater listInflater;
		private boolean scroll = true;

		public TeamListAdapter(Context context) {
			this.listInflater = LayoutInflater.from(context);
		}

		@Override
		public int getCount() {
			return saishiItemCheckedList.size();
		}

		@Override
		public Object getItem(int position) {
			return null;
		}

		@Override
		public long getItemId(int position) {
			return position;
		}

		@Override
		public View getView(final int position, View convertView, ViewGroup parent) {

			if (scrollViewFilter != null && scroll) {
				EDebug.o(BeidanChooseList.this, "adapter触发,scrollto 0");
				scrollViewFilter.scrollTo(0, 0);
				scroll = false;
			}
			if (convertView == null && alViewsList.size() < saishiItemCheckedList.size()) {
				convertView = (RelativeLayout) listInflater.inflate(R.layout.beidan_dialog_saishi_item, null);
				ImageView img = (ImageView) convertView.findViewById(R.id.beidandialogsaishiitem_img_item);
				img.setTag(position);
				Hashtable<String, Object> info = new Hashtable<String, Object>();
				info = BeidanLotteryInfo.getBeiDanLotteryInfo().getSimpleLeagueList().get(position);
				Object[] objs = { (String) info.get(IMAGE_ID), img };

				if (listImageCache.size() < saishiItemCheckedList.size()) {
					listImageCache.add(objs);
					EDebug.o(BeidanChooseList.this, "添加item & the size is " + listImageCache.size());
					if (listImageCache.size() == saishiItemCheckedList.size()) {
						Message msg = handlerChoosePage.obtainMessage(GET_IMAGECACHE_SUCCEED, null);
						handlerChoosePage.sendMessage(msg);
					}
				}
				CheckBox cbxItem = (CheckBox) convertView.findViewById(R.id.beidandialogsaishiitem_cbx_item);
				cbxItem.setText((String) info.get(SAISHI_NAME));
				cbxItem.setChecked(true);
				OnCheckedChangeListener onCheckedChangeListener = new OnCheckedChangeListener() {

					@Override
					public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
						saishiItemCheckedList.set(position, isChecked);
					}
				};
				cbxItem.setOnCheckedChangeListener(onCheckedChangeListener);
				alViewsList.add(convertView);
			}
			return alViewsList.get(position);
		}
	}

	/**
	 * @Title: getMaxTeamNum
	 * @Description: 判断最大场次
	 * @param: @return 设定文件
	 * @return: int 返回类型
	 * @throws
	 */
	private int getMaxTeamNum() {
		int i = 0;
		if (type == 1) {
			i = 8;
		} else if (type == 2) {
			i = 15;
		} else {
			EDebug.o(BeidanChooseList.this, "玩法出错");
		}
		EDebug.o(BeidanChooseList.this, "max team num is " + i);
		return i;
	}

	private ArrayList<ArrayList<Hashtable<String, Object>>> listChild = new ArrayList<ArrayList<Hashtable<String, Object>>>();
	private ArrayList<Hashtable<String, Object>> listGroup = new ArrayList<Hashtable<String, Object>>();
	private ArrayList<ArrayList<View>> listChildView = new ArrayList<ArrayList<View>>();

	/**
	 * @ClassName: BeidanExpandableListAdapter
	 * @Description:北单比赛列表的适配器
	 * @author: Kael gaojian@500wan.com
	 * @date: 2012-4-12 上午11:13:21
	 * 
	 */
	class BeidanExpandableListAdapter extends BaseExpandableListAdapter {
		private LayoutInflater listInflater;

		public BeidanExpandableListAdapter(Context context) {
			this.listInflater = LayoutInflater.from(context);
		}

		@Override
		public Object getChild(int groupPosition, int childPosition) {
			return listChild.get(groupPosition).get(childPosition);
		}

		@Override
		public long getChildId(int groupPosition, int childPosition) {
			return childPosition;
		}

		@Override
		public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
			if (convertView == null) {
				EDebug.o(BeidanChooseList.this, "新建view " + childPosition);
				convertView = (LinearLayout) listInflater.inflate(R.layout.beidan_choose_item, null);
			}
			final BeidanAgainstInfo beiDanAgainstInfo = (BeidanAgainstInfo) listChild.get(groupPosition).get(childPosition).get(INFO);
			TextView homeName = (TextView) convertView.findViewById(R.id.beidanchooseitem_tv_homeName);
			TextView awayName = (TextView) convertView.findViewById(R.id.beidanchooseitem_tv_visiterName);
			TextView leaguName = (TextView) convertView.findViewById(R.id.beidanchooseitem_tv_leagueName);
			TextView rangQiu = (TextView) convertView.findViewById(R.id.beidanchooseitem_tv_rangqiu);
			TextView endTime = (TextView) convertView.findViewById(R.id.beidanchooseitem_tv_ptggEndTime);
			homeName.setText(beiDanAgainstInfo.getHomeSxName());// 主队
			awayName.setText(beiDanAgainstInfo.getGuestSxName());// 客队
			leaguName.setText(beiDanAgainstInfo.getSimpleLeague());// 联赛
			rangQiu.setText(beiDanAgainstInfo.getRangqiu());// 让球
			String strPtggEndTime = beiDanAgainstInfo.getEndTime().substring(10, 16);
			endTime.setText(strPtggEndTime);// 截止时间
			final CheckBox cbxW = (CheckBox) convertView.findViewById(R.id.beidanchooseitem_cbx_W);// 胜
			final CheckBox cbxD = (CheckBox) convertView.findViewById(R.id.beidanchooseitem_cbx_D);// 平
			final CheckBox cbxL = (CheckBox) convertView.findViewById(R.id.beidanchooseitem_cbx_L);// 负

			final int position = (Integer) listChild.get(groupPosition).get(childPosition).get(Key.KEY_POSITION);
			OnCheckedChangeListener onCheckedChangeListener = new OnCheckedChangeListener() {

				@Override
				public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
					switch (buttonView.getId()) {
					case R.id.beidanchooseitem_cbx_W:
						updateTableLottery(position, isChecked, cbxD.isChecked(), cbxL.isChecked(), cbxW, W, beiDanAgainstInfo);
						break;

					case R.id.beidanchooseitem_cbx_D:
						updateTableLottery(position, cbxW.isChecked(), isChecked, cbxL.isChecked(), cbxD, D, beiDanAgainstInfo);
						break;

					case R.id.beidanchooseitem_cbx_L:
						updateTableLottery(position, cbxW.isChecked(), cbxD.isChecked(), isChecked, cbxL, L, beiDanAgainstInfo);
						break;

					default:
						break;
					}

				}
			};
			cbxW.setOnCheckedChangeListener(onCheckedChangeListener);
			cbxD.setOnCheckedChangeListener(onCheckedChangeListener);
			cbxL.setOnCheckedChangeListener(onCheckedChangeListener);

			cbxW.setChecked((Boolean) listChild.get(groupPosition).get(childPosition).get(W));
			cbxD.setChecked((Boolean) listChild.get(groupPosition).get(childPosition).get(D));
			cbxL.setChecked((Boolean) listChild.get(groupPosition).get(childPosition).get(L));
			String c1 = beiDanAgainstInfo.getC1();
			String c3 = beiDanAgainstInfo.getC3();
			String c5 = beiDanAgainstInfo.getC5();
			if (c1.equals(Config.NULLMARK)) {
				cbxW.setText("胜SP" + "--");
			} else {
				cbxW.setText("胜SP" + c1);
			}
			if (c3.equals(Config.NULLMARK)) {
				cbxD.setText("平SP" + "--");
			} else {
				cbxD.setText("平SP" + c3);
			}
			if (c5.equals(Config.NULLMARK)) {
				cbxL.setText("负SP" + "--");
			} else {
				cbxL.setText("负SP" + c5);
			}
			return convertView;
		}

		@Override
		public int getChildrenCount(int groupPosition) {
			return listChild.get(groupPosition).size();
		}

		@Override
		public Object getGroup(int groupPosition) {
			return listGroup.get(groupPosition);
		}

		@Override
		public int getGroupCount() {

			return listGroup.size();
		}

		@Override
		public long getGroupId(int groupPosition) {
			return groupPosition;
		}

		@Override
		public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {

			if (convertView == null) {
				convertView = (LinearLayout) listInflater.inflate(R.layout.beidan_choose_item_title, null);
			}
			TextView tvDate = (TextView) convertView.findViewById(R.id.beidanchooseitemtitle_tv_date);
			TextView tvMatchCount = (TextView) convertView.findViewById(R.id.beidanchooseitemtitle_tv_mtachCount);
			tvDate.setText((String) listGroup.get(groupPosition).get(DATE));
			tvMatchCount.setText((String) listGroup.get(groupPosition).get(Key.KEY_EXPECT));
			ImageView imgExpand = (ImageView) convertView.findViewById(R.id.beidanchooseitemtitle_img_expand);
			if (isExpanded) {
				imgExpand.setBackgroundResource(R.drawable.button_default_pickteam_off_38x38);
			} else {
				imgExpand.setBackgroundResource(R.drawable.button_default_pickteam_on_38x38);
			}
			return convertView;
		}

		@Override
		public boolean hasStableIds() {
			return false;
		}

		@Override
		public boolean isChildSelectable(int groupPosition, int childPosition) {

			return false;
		}

		@Override
		public boolean areAllItemsEnabled() {
			return true;
		}

		public void hideGroup(int groupPos) {

		}
	}

	@Override
	public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {

		ExpandableListView listView = (ExpandableListView) view;

		/**
		 * calculate point (0,0)
		 */
		int npos = view.pointToPosition(0, 0);
		long pos = listView.getExpandableListPosition(npos);
		int childPos = ExpandableListView.getPackedPositionChild(pos);
		int groupPos = ExpandableListView.getPackedPositionGroup(pos);
		if (npos != AdapterView.INVALID_POSITION) {
			if (childPos == listChild.get(groupPos).size() - 1) {

				linearTitle.setAnimation(AnimationUtils.loadAnimation(context, R.anim.fade));
				linearTitle.setVisibility(View.GONE);
			} else {
				updateTitleView(groupPos);
			}
			if (childPos == AdapterView.INVALID_POSITION) {

				updateTitleView(groupPos);

			}
		}
	}

	/**
	 * @Title: updateTitleView
	 * @Description: 修改标题
	 * @param: @param groupPos 设定文件
	 * @return: void 返回类型
	 * @throws
	 */
	private void updateTitleView(final int groupPos) {
		linearTitle.setVisibility(View.VISIBLE);
		if (!listGroup.isEmpty()) {
			tvDate.setText((String) listGroup.get(groupPos).get(DATE));
			EDebug.o(BeidanChooseList.this, "item count is " + listGroup.get(groupPos).get(ITEM_COUNT));
			tvSaishiCount.setText((String) listGroup.get(groupPos).get(Key.KEY_EXPECT));
		} else {
			linearTitle.setVisibility(View.GONE);
		}
		if (expandableListViewContent.isGroupExpanded(groupPos)) {
			imgExpand.setBackgroundResource(R.drawable.button_default_pickteam_off_38x38);
		} else {
			imgExpand.setBackgroundResource(R.drawable.button_default_pickteam_on_38x38);
		}
		linearTitle.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				if (expandableListViewContent.isGroupExpanded(groupPos)) {
					imgExpand.setBackgroundResource(R.drawable.button_default_pickteam_on_38x38);
					expandableListViewContent.collapseGroup(groupPos);
					expandableListViewContent.setSelectedGroup(groupPos);
				} else {
					imgExpand.setBackgroundResource(R.drawable.button_default_pickteam_off_38x38);
					expandableListViewContent.expandGroup(groupPos);
				}

			}
		});

	}

	@Override
	public void onScrollStateChanged(AbsListView view, int scrollState) {

	}

	private Dialog filterDialog;
	private int rangqiuType;
	private int rangqiuType_ = 0;
	private int peilvType;
	private int peilvType_ = 0;
	private ArrayList<String> listSelectedLeagueNmae = new ArrayList<String>();
	private ArrayList<RadioButton> listRbRangqiu = new ArrayList<RadioButton>();
	private ArrayList<RadioButton> listRbPeilv = new ArrayList<RadioButton>();
	private ScrollView scrollViewFilter;

	/**
	 * @Title: showDialogFilter
	 * @Description: 显示筛选框
	 * @param: 设定文件
	 * @return: void 返回类型
	 * @throws
	 */
	private void showDialogFilter() {
		if (filterDialog == null) {
			filterDialog = new Dialog(context, R.style.dialogNoFloating);
		}
		filterDialog.getWindow().setContentView(R.layout.beidan_filter_page);
		// rangqiuType_ = 0;
		// peilvType_ = 0;
		teamListAdapter = new TeamListAdapter(context);
		gridSaishiList = (GridView) filterDialog.getWindow().findViewById(R.id.beidanfilterpage_grid_saishiList);
		gridSaishiList.setAdapter(teamListAdapter);
		scrollViewFilter = (ScrollView) filterDialog.getWindow().findViewById(R.id.beidanfilterpage_scrollview_main);

		RadioButton rbRangqiuA = (RadioButton) filterDialog.getWindow().findViewById(R.id.beidanfilterpage_rb_rangqiuA);
		RadioButton rbRangqiuR = (RadioButton) filterDialog.getWindow().findViewById(R.id.beidanfilterpage_rb_rangqiu);
		RadioButton rbRangqiuU = (RadioButton) filterDialog.getWindow().findViewById(R.id.beidanfilterpage_rb_unRangqiu);
		listRbRangqiu.clear();
		listRbRangqiu.add(rbRangqiuA);
		listRbRangqiu.add(rbRangqiuR);
		listRbRangqiu.add(rbRangqiuU);
		listRbRangqiu.get(rangqiuType).setChecked(true);

		RadioButton rbPeilvA = (RadioButton) filterDialog.getWindow().findViewById(R.id.beidanfilterpage_rb_peilvA);
		RadioButton rbPeilvL = (RadioButton) filterDialog.getWindow().findViewById(R.id.beidanfilterpage_rb_peilvL);
		RadioButton rbPeilvM = (RadioButton) filterDialog.getWindow().findViewById(R.id.beidanfilterpage_rb_peilvM);
		RadioButton rbPeilvH = (RadioButton) filterDialog.getWindow().findViewById(R.id.beidanfilterpage_rb_peilvH);
		listRbPeilv.clear();
		listRbPeilv.add(rbPeilvA);
		listRbPeilv.add(rbPeilvL);
		listRbPeilv.add(rbPeilvM);
		listRbPeilv.add(rbPeilvH);
		listRbPeilv.get(peilvType).setChecked(true);

		OnClickListener onClickListener = new OnClickListener() {

			@Override
			public void onClick(View v) {

				switch (v.getId()) {
				// 取消
				case R.id.beidanfilterpage_btn_cancel:
					filterDialog.dismiss();
					break;
				// 提交
				case R.id.beidanfilterpage_btn_submit:
					EDebug.o(BeidanChooseList.this, "完成按下");
					listSelectedLeagueNmae.clear();
					for (int i = 0; i < saishiItemCheckedList.size(); i++) {
						Hashtable<String, Object> hashtableSimpleLeague = new Hashtable<String, Object>();
						hashtableSimpleLeague = BeidanLotteryInfo.getBeiDanLotteryInfo().getSimpleLeagueList().get(i);
						hashtableSimpleLeague.put(IS_CHECKED, saishiItemCheckedList.get(i));
						if (saishiItemCheckedList.get(i)) {
							listSelectedLeagueNmae.add((String) hashtableSimpleLeague.get(SAISHI_NAME));
							EDebug.o(BeidanChooseList.this, "筛选球队" + (String) hashtableSimpleLeague.get(SAISHI_NAME));
						}
					}
					peilvType = peilvType_;
					rangqiuType = rangqiuType_;
					updateListExpandadble(listContent, false, false);
					beiDanExpandableListAdapter.notifyDataSetChanged();
					filterDialog.dismiss();

					Message msgToGroup = BeidanAgp.handlerBeidanAgp.obtainMessage(BeidanAgp.SHOW_FILTER, null);
					BeidanAgp.handlerBeidanAgp.sendMessage(msgToGroup);
					break;
				// 全选
				case R.id.beidanfilterpage_btn_quanxuan:
					EDebug.o(BeidanChooseList.this, "do quanxuan !!!!!");
					for (int i = 0; i < alViewsList.size(); i++) {
						View view = alViewsList.get(i);
						CheckBox cb = (CheckBox) view.findViewById(R.id.beidandialogsaishiitem_cbx_item);
						cb.setChecked(true);
					}
					break;
				// 反选
				case R.id.beidanfilterpage_btn_fanxuan:
					EDebug.o(BeidanChooseList.this, "saishiItemCheckedList size is " + saishiItemCheckedList.size() + "alViewsList size is " + alViewsList.size());
					for (int i = 0; i < alViewsList.size(); i++) {
						View view = alViewsList.get(i);
						CheckBox cb = (CheckBox) view.findViewById(R.id.beidandialogsaishiitem_cbx_item);
						boolean b = cb.isChecked();
						cb.setChecked(!b);
					}
					break;

				default:
					break;
				}
			}
		};

		android.widget.RadioGroup.OnCheckedChangeListener onCheckedChangeListenerRangqiu = new RadioGroup.OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(RadioGroup group, int checkedId) {

				switch (checkedId) {
				// 全部
				case R.id.beidanfilterpage_rb_rangqiuA:
					rangqiuType_ = 0;
					break;
				// 让球
				case R.id.beidanfilterpage_rb_rangqiu:
					rangqiuType_ = 1;
					break;
				// 非让球
				case R.id.beidanfilterpage_rb_unRangqiu:
					rangqiuType_ = 2;
					break;

				default:
					break;
				}

			}
		};
		android.widget.RadioGroup.OnCheckedChangeListener onCheckedChangeListenerPeilv = new RadioGroup.OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(RadioGroup group, int checkedId) {

				switch (checkedId) {
				// 全部 选择全部区间
				case R.id.beidanfilterpage_rb_peilvA:
					peilvType_ = 0;
					break;
				// 1.5以下 高命中区间
				case R.id.beidanfilterpage_rb_peilvL:
					peilvType_ = 1;
					break;
				// 1.5-2.0 实力赔率区间
				case R.id.beidanfilterpage_rb_peilvM:
					peilvType_ = 2;
					break;
				// 2.0以上 高额回报区间
				case R.id.beidanfilterpage_rb_peilvH:
					peilvType_ = 3;
					break;
				default:
					break;
				}

			}
		};
		// 取消
		ImageButton btnCancel = (ImageButton) filterDialog.getWindow().findViewById(R.id.beidanfilterpage_btn_cancel);
		btnCancel.setOnClickListener(onClickListener);
		// 提交
		Button btnSubmit = (Button) filterDialog.getWindow().findViewById(R.id.beidanfilterpage_btn_submit);
		btnSubmit.setOnClickListener(onClickListener);
		// 全选
		Button btnQuanxuan = (Button) filterDialog.getWindow().findViewById(R.id.beidanfilterpage_btn_quanxuan);
		btnQuanxuan.setOnClickListener(onClickListener);
		// 反选
		Button btnFanxuan = (Button) filterDialog.getWindow().findViewById(R.id.beidanfilterpage_btn_fanxuan);
		btnFanxuan.setOnClickListener(onClickListener);
		// 让球
		RadioGroup rgRangqiu = (RadioGroup) filterDialog.getWindow().findViewById(R.id.beidanfilterpage_rg_rangqiu);
		rgRangqiu.setOnCheckedChangeListener(onCheckedChangeListenerRangqiu);
		// 赔率
		RadioGroup rgPeilv = (RadioGroup) filterDialog.getWindow().findViewById(R.id.beidanfilterpage_rg_peilv);
		rgPeilv.setOnCheckedChangeListener(onCheckedChangeListenerPeilv);

		filterDialog.setOnDismissListener(new Dialog.OnDismissListener() {

			@Override
			public void onDismiss(DialogInterface dialog) {

				if (imageListCache != null) {
					imageListCache.stop();
				}
			}
		});

		if (listImageCache.size() == saishiItemCheckedList.size()) {
			Message msg = handlerChoosePage.obtainMessage(GET_IMAGECACHE_SUCCEED, null);
			handlerChoosePage.sendMessage(msg);
		}

		filterDialog.show();
	}

	@Override
	public void setSportteryBuyLotteryPage(SportteryBuyLottery buyLotteryPage) {
		this.buyLotteryPage = buyLotteryPage;
	}

}
